#include "GameData.h"

GameData *data = nullptr;

GameData* GameData::getInstance() {
	if (data == nullptr) {
		data = new GameData();
		data->initData();
	}
	return data;
}

__Dictionary* GameData::getArrowProperty(const char* arrowType) {
	return dynamic_cast<__Dictionary *>(m_arrowData->objectForKey(arrowType));
}

__Dictionary* GameData::getBowProPerty(const char* bowType) {
	return dynamic_cast<__Dictionary *>(m_bowData->objectForKey(bowType));
}

__Dictionary* GameData::getmonsterProPerty(const char* monsterType) {
	return dynamic_cast<__Dictionary *>(m_monsterData->objectForKey(monsterType));
}

void GameData::initData() {
	m_bowData = __Dictionary::createWithContentsOfFile(BOWTYPE_PLIST_NAME);
	CC_SAFE_RETAIN(m_bowData);
	m_arrowData = __Dictionary::createWithContentsOfFile(ARROWTYPE_PLIST_NAME);
	CC_SAFE_RETAIN(m_arrowData);
	m_monsterData = __Dictionary::createWithContentsOfFile(MONSTERTYPE_PLIST_NAME);
	CC_SAFE_RETAIN(m_monsterData);
}